import json



if __name__ == '__main__':

  file_config = r'/Users/edgar/conf.json'
  content = open(file_config,'r').read()
  if content.startswith(u'\ufeff'):
    content = content.encode('utf8')[3:].decode('utf8')
  json_data = json.loads(content)
  # print('这是文件中的json数据：',json_data)
  dict_map = json_data['device-mapping']
  # print(dict_map)
  deviceIds = []
  for i in dict_map:
    deviceIds.append(dict_map[i])
  print(deviceIds)
  print('*'*30)
  # deviceIds.remove('31011418001191001001')

  # 2020-08-26_00:00:00.log
  for i in range(25, 31):
    file_log = r'/Users/edgar/2020-08-' + str(i) + '_00:00:00.log'
    f = open(file_log, 'r', encoding="utf-8")
    line = f.readline()
    if len(deviceIds) < 1:
      break
    while line:
      for id in deviceIds:
        # str_id = 'DeviceId:[%s]' % id
        if id in line:
          print(line)
          print('--- found in ', file_log)
          deviceIds.remove(id)
          break
      line = f.readline()
    f.close()
    print('>>> end ', file_log)
  print(deviceIds)
